﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProvideProduct.aspx.cs" Inherits="Catering.yl.Daily.ProvideProduct" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title> 
     <link href="../../../Style/ZHJG/zhezhao.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/zhezhao.js" type="text/javascript"></script>
    <script src="../../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        //显示添加
        function Add() {
            $("#txt_PName").val("");
            $("#txt_PType").val("");
            $("#txt_PUint").val("");
            $("#txt_PNums").val("");
            $("#txt_PDesc").val("");
            $("#btnEdit").hide();
            $("#btnAdd").show();
            divshow("main", "bg");
        }
        //添加数据
        function btn_Add() {
            var txt_PName = $("#txt_PName").val();
            if (txt_PName == "") return;
            var txt_PType = $("#txt_PType").val();
            if (txt_PType == "") return;
            var txt_PUint = $("#txt_PUint").val();
            if (txt_PUint == "") return;
            var txt_PNums = $("#txt_PNums").val();
            if (txt_PNums == "") return;
            var txt_PDesc = $("#txt_PDesc").val();
            if (txt_PDesc == "") return;

            $.ajax({
                type: "Post",
                url: "ProvideProduct.aspx/Add",
                data: "{'PName':'" + txt_PName + "','PType':'" + txt_PType + "','PUint':'" + txt_PUint + "','PNums':'" + txt_PNums + "','PDesc':'" + txt_PDesc + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",

                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = window.location.href;
                    }
                }
            });
        }
        function Edit(cid) {
            $("#HidID").val(cid);

            $.ajax({
                type: "Post",
                url: "ProvideProduct.aspx/Get",
                data: "{'_id':'" + cid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#txt_id").val(data.d[0] == null ? "" : data.d[0]);
                    $("#txt_PName").val(data.d[1] == null ? "" : data.d[1]);
                    $("#txt_PType").val(data.d[2] == null ? "" : data.d[2]);
                    $("#txt_PUint").val(data.d[3] == null ? "" : data.d[3]);
                    $("#txt_PNums").val(data.d[4] == null ? "" : data.d[4]);
                    $("#txt_PDesc").val(data.d[5] == null ? "" : data.d[5]);

                    $("#btnEdit").show();
                    $("#btnAdd").hide();
                    divshow("main", "bg");
                }
            });
        }
        //修改数据
        function btn_Edit() {
            var txt_PName = $("#txt_PName").val();
            var txt_PType = $("#txt_PType").val();
            var txt_PUint = $("#txt_PUint").val();
            var txt_PNums = $("#txt_PNums").val();
            var txt_PDesc = $("#txt_PDesc").val();
            var cid = $("#txt_id").val();

            $.ajax({
                type: "Post",
                url: "ProvideProduct.aspx/Edit",
                data: "{'_id':'" + cid + "','PName':'" + txt_PName + "','PType':'" + txt_PType + "','PUint':'" + txt_PUint + "','PNums':'" + txt_PNums + "','PDesc':'" + txt_PDesc + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = window.location.href;
                    }
                }
            });
        }
        </script>   
</head>
<body>
    <form id="form1" runat="server">
        <asp:HiddenField ID="HidID" runat="server" />
    <div style="height: 36px; line-height: 40px; color:red; font-size: 13px; background-color:#0f4a98; width:998px; margin:auto"> 
            &nbsp;&nbsp;当前位置：日报管理->设备设施->顾客财产清单->提供产品
       </div>
        <div style="height: 36px;  font-size: 13px; margin-left:30px;width:998px; margin:auto">            
            <asp:Button ID="Button1" style="float:right; margin:8px 0px" runat="server" Text="导出Excel" />
            <input id="New" type="button" value="新增" style="float:right; margin:8px 0px" onclick="Add()"/> 
            <table style="width:80%; height:36px; text-align:right">
                <tr>
                    <td style="width:17%">编号:</td>
                    <td style="text-align:left;width:17%"><%=Session["SNumber"]%></td>
                    <td style="width:17%">提供单位:</td>
                    <td style="text-align:left;width:17%"><%=Session["Company"]%></td>
                    <td style="width:17%">联系人:</td>
                    <td style="text-align:left;width:15%"><%=Session["Contacts"]%></td>
                </tr>
                <tr>
                    <td>顾客名称:</td>
                    <td style="text-align:left"><%=Session["CustomerName"]%></td>
                    <td>电话:</td>
                    <td style="text-align:left"><%=Session["Phone"]%></td>
                </tr>                
            </table>
            <div style="padding: 0px;text-align: center;height: 29px; margin-top:10px">
            <table cellpadding="0" cellspacing="0" width="100%" style="border-left:1px solid #8b8888;border-top:1px solid #8b8888;">
                <thead>
                    <tr style="background:url(../../../Images/th_02bg.gif) repeat-x 0px 0px; height:29px;" >
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">序号
                        </td >
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">名称
                        </td>
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">型号规格
                        </td>
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">单位
                        </td>
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">数量
                        </td>
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">备注
                        </td>
                        <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">操作
                        </td>                        
                    </tr>
                </thead>
                <tbody>
                    <asp:Repeater ID="Rep_PPlan" runat="server" OnItemCommand="Rep_Plan_ItemCommand">
                        <ItemTemplate>
                            <tr>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <%#Eval("tempId")%>                                    
                                </td>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <%#Eval("PName")%>
                                </td>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <%#Eval("PType")%>
                                </td>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <%#Eval("PUint")%>
                                </td>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <%#Eval("PNums")%>
                                </td>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <%#Eval("PDesc")%>
                                </td>
                                <td style="border-bottom:1px solid #8b8888;border-right:1px solid #8b8888">
                                    <img alt="" title="编辑" src="../../../Images/file.gif" style="cursor: pointer;" onclick="Edit('<%#Eval("id")%>')"/>
                                    <asp:ImageButton ToolTip="删除" ID="ImageButton1" runat="server" ImageUrl="../../../Images/trash.gif" OnClientClick="return confirm('确认删除？');"
                                        CommandArgument='<%#Eval("id")%>' CommandName="del" />
                                </td>                                
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </tbody>
            </table>
                        
            <table style="width:80%; height:20px; text-align:right">
                <tr>
                    <td style="width:17%">填表人:</td>
                    <td style="text-align:left;width:17%"><%=Session["LPerson"]%></td>
                    <td style="width:17%">年月日:</td>
                    <td style="text-align:left;width:17%"><%=Session["SaveDate"]%></td>
                    <td style="width:17%;">&nbsp;</td>
                    <td style="width:15%;"></td>
                </tr>                   
            </table>            
            
        </div>
       </div>
            <!--弹出层-->
        <div id="bg" class="bg">
        </div>
        <div id="main" class="center_div" style="width: 400px; height: 300px;margin:auto;left:35%;top:20%;">
            <div class="div_0207" style="width: 398px; height: 100%; margin: 0px;">
                <h1>
                    <img src="../../../Images/cp_h1_03.gif" />添加提供产品</h1>
                <table width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td height="40" class="auto-style1">
                            名称:
                        </td>
                        <td>
                            <asp:HiddenField ID="txt_id" runat="server" />   
                            <asp:TextBox ID="txt_PName" runat="server" CssClass="input_bg" Width="100px"></asp:TextBox>                          
                        </td>
                        <td width="85" height="40" align="right">型号规格:
                        </td>
                        <td width="65" height="40" align="right">
                            <asp:TextBox ID="txt_PType" runat="server" CssClass="input_bg" Width="100px"></asp:TextBox>
                        </td>                        
                    </tr>
                    <tr>
                        <td height="40" align="right" class="auto-style1">单位:
                        </td>
                        <td>
                            <asp:TextBox ID="txt_PUint" runat="server" CssClass="input_bg" Width="100px"></asp:TextBox>                          
                        </td>
                        <td width="85" height="40" align="right">数量:
                        </td>
                        <td>
                            <asp:TextBox ID="txt_PNums" runat="server" CssClass="input_bg" Width="105"></asp:TextBox>                          
                        </td>               
                    </tr>  
                    <tr>
                        <td height="40" align="right" class="auto-style1">备注:
                        </td>
                        <td>
                            <asp:TextBox ID="txt_PDesc" runat="server" CssClass="input_bg" Width="100px"></asp:TextBox>                          
                        </td>                                     
                    </tr>                       
                </table>
                <table width="100%">
                    <tr>
                        <td height="30" align="right">
                            <input type="button" id="btnAdd" onclick="btn_Add()" class="input_btn_a" value="提交" />
                            <input type="button" id="btnEdit" onclick="btn_Edit()" class="input_btn_a" value="提交" />
                        </td>
                        <td>
                            <input type="button" id="but_Close" onclick='divhidel("main", "bg")' class="input_btn_a"
                                value="关闭" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </form>
</body>
</html>
